package cn.project.lemontree.service.impl;

import cn.project.lemontree.bean.Notice_Per;
import cn.project.lemontree.dao.Notice_PerDao;
import cn.project.lemontree.service.Notice_PerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("notice_perService")
public class Notice_PerServiceimpl extends ServiceImpl<Notice_PerDao, Notice_Per> implements Notice_PerService {
    @Resource
    private Notice_PerDao notice_perDao;

    @Override
    public List<Notice_Per> searchNotice(Integer user_id, Integer role){
        List<Notice_Per> list =  notice_perDao.searchNotice(user_id,role);
        for(Notice_Per notice_per : list){
            notice_per.setIsread(1);
            notice_perDao.update(notice_per.getId());
        }
        return list;
    }

    @Override
    public int count(Integer user_id,Integer role){
        return notice_perDao.count(user_id,role);
    }
}
